package com.qf.commons.event.mq.kafka.listener;

import com.qf.commons.event.core.standrad.ConsumerStandrad;
import com.qf.commons.event.entity.QphoneMessage;
import org.springframework.amqp.utils.SerializationUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.annotation.KafkaListener;

/**
 * description:
 * author: Ken
 * 公众号：Java架构栈
 */
public class MsgListener {

    @Autowired
    private ConsumerStandrad consumerStandrad;

    @KafkaListener(groupId = "group-${spring.application.name}", topics = "#{@eventTypes}")
    public void handler(byte[] msg){
        //反序列化
        QphoneMessage qphoneMessage = (QphoneMessage) SerializationUtils.deserialize(msg);
        //调用上层的接口处理对象
        consumerStandrad.msgHandler(qphoneMessage);
    }
}
